<?php
define ( "IN_KEKE", TRUE );
include '../app_comm.php';
require S_ROOT . 'update_3_6_1/file/kppw26.php';
require S_ROOT . 'update_3_6_1/DbUtilities.php';
	$DbUtilities = new DbUtilities ();
	$DbUtilities->dbUpdate ( $dbArr );
	foreach ($dbArr as $table=>$fields){
		$filepath = S_ROOT . 'update_3_6_1/sqldata/'.$table.'.php';
		if(file_exists($filepath)){
			require $filepath;
		} 
	}
	unset ( $dbArr );
	unset ( $DbUtilities );
	$file_obj = new keke_file_class();
	$file_obj->delete_files(S_ROOT."/data/data_cache/");
	$file_obj->delete_files(S_ROOT."/data/tpl_c/");
	
db_factory::execute("REPLACE INTO `".TABLEPRE."witkey_resource_submenu` (`submenu_id`, `submenu_name`, `menu_name`, `listorder`, `status`) VALUES ('34', '增值工具', 'tool', '3', '1')");
db_factory::execute("REPLACE INTO `".TABLEPRE."witkey_basic_config` (`config_id`, `k`, `v`, `type`, `desc`, `listorder`) VALUES ('120', 'css_auto_fit', '1', NULL, 'css自适应', NULL)");


db_factory::execute("REPLACE INTO `".TABLEPRE."witkey_resource` (`resource_id`, `resource_name`, `resource_url`, `submenu_id`, `listorder`, `accesscontrol`) VALUES ('28', '模板管理', 'index.php?do=config&view=tpl', '12', '1', NULL)");
db_factory::execute("REPLACE INTO `".TABLEPRE."witkey_resource` (`resource_id`, `resource_name`, `resource_url`, `submenu_id`, `listorder`, `accesscontrol`) VALUES ('172', '关键字编辑', 'index.php?do=article&view=keyword_edit', '50', '1', NULL)");
db_factory::execute("REPLACE INTO `".TABLEPRE."witkey_resource` (`resource_id`, `resource_name`, `resource_url`, `submenu_id`, `listorder`, `accesscontrol`) VALUES ('171', '关键字列表', 'index.php?do=article&view=keyword_list', '50', '0', NULL)");
db_factory::execute("REPLACE INTO `".TABLEPRE."witkey_resource_submenu` (`submenu_id`, `submenu_name`, `menu_name`, `listorder`, `status`) VALUES ('50', '关键字管理', 'article', '7', '1')");



$autoshop_colinfo = db_factory::get_one("SHOW COLUMNS FROM ".TABLEPRE."witkey_space WHERE field ='autoshop'");
if(!$autoshop_colinfo['Field']){
	db_factory::execute("alter table ".TABLEPRE."witkey_space add column autoshop int(2)");
	
}

db_factory::execute("UPDATE `".TABLEPRE."witkey_space` SET `autoshop`='1'");
db_factory::execute("REPLACE INTO `".TABLEPRE."witkey_basic_config` VALUES ('128', 'autoshop', '1', null, null, null);");

	header('Refresh: 3; url=../index.php?do=index');
	echo '升级成功...<br />';
	echo '页面跳转中...<br />';
